﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// AdminMainMenu.xaml 的交互逻辑
    /// </summary>
    public partial class AdminMainMenu : Window
    {
        public AdminMainMenu()
        {
            InitializeComponent();
        }
        string strCon = Properties.Resources.strCON;
        public AdminMainMenu(string adminName)
        {
            InitializeComponent();
            labelName.Content = adminName;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.frame.Navigate(new Uri("AdminChoose" + ".xaml", UriKind.Relative));
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(strCon);
            con.Open();

            SqlCommand cmd = new SqlCommand("update [admin] set status=@num where adminNumber=@id", con);
            cmd.Parameters.Add("@id", SqlDbType.Int, 10).Value = Convert.ToInt32(labelName.Content);
            cmd.Parameters.Add("@num", SqlDbType.Int, 10).Value = 0;
            cmd.ExecuteNonQuery();
            con.Close();
            this.Close();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            this.frame.Navigate(new Uri(btn.Tag.ToString() + ".xaml", UriKind.Relative));
        }
    }
}
